<!--#
layout("/layouts/platform.html"){
#-->
<div id="app" v-cloak>
    <el-row class="header navbar bg-white shadow">
        <!--搜索框-->
        <div class="btn-group tool-button mt5">
            <el-input v-model="pageForm.keyWord" @keyup.enter.native="doSearch" placeholder="按手机号搜索(不加前缀)"
                      size="medium"></el-input>
        </div>
        <!--搜索按钮-->
        <div class="btn-group tool-button mt5">
            <el-button slot="append" icon="el-icon-search" @click="doSearch" size="medium"></el-button>
        </div>
    </el-row>
    <el-row class="el-table-container">
        <el-table
                :data="tableData"
                size="small"
                header-align="center"
                style="width: 100%"
                :default-sort="{prop: 'ttl', order: 'ascending'}"
        >
            <!--手机号-->
            <el-table-column
                    prop="phone"
                    label="手机号"
                    header-align="center"
                    :show-overflow-tooltip="true"
                    align="center">
                <template slot-scope="scope">
                    <span>{{'(+' + scope.row.phonePrefix + ')' + scope.row.phone}}</span>
                </template>
            </el-table-column>
            <!--验证码-->
            <el-table-column
                    label="验证码"
                    prop="code"
                    header-align="center"
                    :show-overflow-tooltip="true"
                    align="center"
            >
            </el-table-column>
            <!--操作类型-->
            <el-table-column
                    label="操作类型"
                    prop="type"
                    header-align="center"
                    :show-overflow-tooltip="true"
                    align="center">
                <template slot-scope="scope">
                    <span v-if="scope.row.type == 'register'">注册</span>
                    <span v-else-if="scope.row.type == 'updatePhone'">修改手机号</span>
                    <span v-else-if="scope.row.type == 'resetLoginPwd'">重置登录密码</span>
                    <span v-else-if="scope.row.type == 'resetTradePwd'">重置交易密码</span>
                </template>
            </el-table-column>
            <!--有效时间(秒)-->
            <el-table-column
                    sortable
                    label="有效时间(秒)"
                    prop="ttl"
                    header-align="center"
                    :show-overflow-tooltip="true"
                    :sort-method="sortMethod"
                    align="center">
            </el-table-column>
        </el-table>
    </el-row>

    <!--分页容器-->
    <el-row class="el-pagination-container">
        <el-pagination
                @size-change="pageSizeChange"
                @current-change="pageNumberChange"
                :current-page="pageForm.pageNumber"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="pageForm.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pageForm.totalCount">
        </el-pagination>
    </el-row>
</div>
<script>
    new Vue({
        el: "#app",
        data: function () {
            var self = this;
            return {
                dialogVisible: false,
                tableData: [],
                pageForm: {
                    pageNumber: 1,
                    pageSize: 10,
                    totalCount: 0,
                    keyWord: "",
                },
            }
        },
        methods: {
            sortMethod: function (a, b) {
                return Number(a.ttl) - Number(b.ttl);
            },
            pageNumberChange: function (val) {//页码更新操作
                this.pageForm.pageNumber = val;
                this.pageData();
            },
            pageSizeChange: function (val) {//分页大小更新操作
                this.pageForm.pageSize = val;
                this.pageData();
            },
            pageData: function () {//加载分页数据
                var self = this;
                sublime.showLoadingbar();//显示loading
                if (self.searchDate) {
                    self.pageForm.searchDate = self.searchDate.toString();
                } else {
                    self.pageForm.searchDate = "";
                }
                $.post(base + "/platform/user/manager/verifyCode/data", self.pageForm, function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code === 0) {
                        self.tableData = data.data.list;
                        self.pageForm.totalCount = data.data.totalCount;
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            doSearch: function () {
                this.pageForm.pageNumber = 1;
                this.pageData();
            },
        },
        created: function () {
            this.pageData();
        }
    });
</script>

<!--#
}
#-->